from typing import List


class Solution:
    def intersection(self: List[int], nums2: List[int]) -> List[int]:
        self.sort()
        nums2.sort()
        length1, length2 = len(self), len(nums2)
        res = list()
        index1 = index2 = 0
        while index1 < length1 and index2 < length2:
            num1 = self[index1]
            num2 = nums2[index2]
            if num1 == num2:
                # 保证加入元素的唯一性
                if not res or num1 != res[-1]:
                    res.append(num1)
                index1 += 1
                index2 += 1
            elif num1 < num2:
                index1 += 1
            else:
                index2 += 1
        return res


int_nums1 = [1, 2, 2, 1]
int_nums2 = [2, 2]
print(Solution.intersection(int_nums1, int_nums2))
